package server;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
	public static void main(String[] args) throws Exception{
		ServerSocket ss=new ServerSocket(8888);
		while(true){
			Socket s=ss.accept();
			BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
			PrintWriter out = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
			String msg=null;
			while((msg=in.readLine())!=null){
				Hello hello=new HelloImpl();
				String result=hello.sayHello(msg);
				out.println(result);
				out.flush();
			}
			out.close();
		}
	}
}
